package org.saxonextensions.eml.dispatcher;

import java.io.File;

/**
 * Command line tool that dispatch all .eml files from given directory
 *
 * @author Ivan Latysh <ivan@yourmail.com>
 * @version 0.1
 * @since 12-May-2009 3:25:57 PM
 */
public class EMLFileDispatcher extends AbstractFileEMLDispatcher {

  /**
   * Main method
   *
   * @param args commanf line arguments
   */
  public static void main(String[] args) throws Exception {
    // get arguments
    if (args.length!=1) {
      printUsage();
      return;
    }

    File directory = new File(args[0]);

    // check directory
    if (!directory.isDirectory()) {
      System.err.println("{"+directory.getAbsolutePath()+"} is not a directory.");
    }

    // create a new dispatcher
    EMLFileDispatcher dispatcher = new EMLFileDispatcher();

    // dispatch mail
    dispatcher.dispatchAll(directory);

  }

  public static void printUsage() {
    System.out.println("Usage:   ");
    System.out.println("      dispatch smtp_server ");
  }

}
